package com.sport.video.db.base;

/**
 * Created by Gred
 */
import java.util.List;
import java.util.Map;

/**
* 基础Service
*@Author Gred
*@Date 2019/3/5 20:49
*@version 1.0
**/
public abstract class IService<T> {
    private IMapper<T> mapper;

    public IService() {
    }

    public abstract IMapper<T> getMapper();

    public List<T> list(Map paramMap) {
        return this.getMapper().query(paramMap);
    }

    public int count(Map paramMap) {
        return this.getMapper().count(paramMap);
    }

    public void resetMapper(IMapper<T> mapper) {
        this.mapper = mapper;
    }

    public T add(T srcEntity) {
        int count = this.getMapper().insert(srcEntity);
        return count > 0 ? srcEntity : null;
    }

    public T edit(T srcEntity) {
        int count = this.getMapper().update(srcEntity);
        return count > 0 ? srcEntity : null;
    }

    public int del(T srcEntity) {
        return this.getMapper().delete(srcEntity);
    }

    public T findByMap(Map paramMap) {
        return this.getMapper().getInfoByMap(paramMap);
    }

    public T findById(String uuid) {
        return this.getMapper().getInfoById(uuid);
    }

}